package com.xiaomaoguai.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description :
 * @FileName: NewsPaper.java
 * @Author :WeiHui.Zhang
 * @Data : 2015年6月15日 下午12:58:06
 * @Version:V1.00
 */
public class NewsPaper implements INewsPaper {

    private List<IOrderMan> orderList = new ArrayList<IOrderMan>();

    @Override
    public void registerPaper(IOrderMan orderMan) {
        orderList.add(orderMan);
    }

    @Override
    public void removeRegister(IOrderMan orderMan) {
        if (orderList.contains(orderMan)) {
            orderList.remove(orderMan);
        }
    }

    @Override
    public void postNewsPaper() {
        for (IOrderMan iOrderMan : orderList) {
            System.out.println("发报纸给 ： " + iOrderMan.getName());
            iOrderMan.hasNewsPaper();
        }
    }

}
